;(function(b,c){
    b('*').hover(function(){
        b(this).data(c,1)
    }, function(){
        b(this).data(c,0)
    }).data(c,0);
    b[c]=function(a){
        return b(a)[c]()
    };
    b.fn[c]=function(a){
        a=0;
        b(this).each(function(){
            a+=b(this).data(c)
        });
        return a>0
    }
})(jQuery,'isHovered');
(function($){
    $.jMenu={
        defaults:{
            ulWidth:'auto',
            absoluteTop:30,
            absoluteLeft:0,
            effects:{
                effectSpeedOpen:350,
                effectSpeedClose:350,
                effectTypeOpen:'slide',
                effectTypeClose:'slide',
                effectOpen:'linear',
                effectClose:'linear'
            },
            TimeBeforeOpening:200,
            TimeBeforeClosing:200,
            animatedText:false,
            paddingLeft:7
        },
        opts: {},
        ULWidth: '',
        init:function(options){
            this.opts=$.extend({},$.jMenu.defaults,options);
            var opts = this.opts;
            $("#jMenu a:not(.fNiv)").each(function(){
                var $thisChild=$(this);
                if($.jMenu._IsParent($thisChild))
                    $thisChild.addClass('isParent');
                if(opts.animatedText)
                    $.jMenu._animateText($thisChild);
                $thisChild.bind({mouseover:function(){
                    $.jMenu._hide($thisChild);
                    $.jMenu._showNextChild($thisChild);
                }
                });
            });
            $('#jMenu li a.fNiv').bind({mouseover:function(){
                var $this=$(this);
                var $child=$this.next();
                this.ULWidth=$.jMenu._returnUlWidth($this);
                $.jMenu._closeList($("#jMenu ul"));
                if($child.is(':hidden'))
                    $.jMenu._showFirstChild($this);
                }
            });
            $('#jMenu').bind({mouseleave:function(){
                setTimeout(function(){
                    $.jMenu._closeAll();
                    },opts.TimeBeforeClosing);
            }
            });
            },
        _showFirstChild:function(el){
            const opts = this.opts;
            if($.jMenu._IsParent(el)){
                var SecondList=el.next();
                if(SecondList.is(":hidden")) {
                    var position=el.position();
                    SecondList.css({
                        top:position.top+opts.absoluteTop,
                        left:position.left+opts.absoluteLeft,
                        width:this.ULWidth}).children().css({width:this.ULWidth});
                    $.jMenu._show(SecondList);}
            } else return false;
        },
        _showNextChild:function(el){
            if($.jMenu._IsParent(el)) {
                var ChildList=el.next();
                if(ChildList.is(":hidden")) {
                    var position=el.position();
                    ChildList.css({
                        top:position.top,
                        left:position.left+this.ULWidth,
                        width:this.ULWidth}).children().css({width:this.ULWidth});
                    $.jMenu._show(ChildList);}
            } else
                return false;
            },
        _hide:function(el){
            if($.jMenu._IsParent(el)&&!el.next().is(':hidden')) $.jMenu._closeList(el.next());
            else if(($.jMenu._IsParent(el)&&el.next().is(':hidden'))||!$.jMenu._IsParent(el))
                $.jMenu._closeList(el.parent().parent().find('ul'));
            else return false;
            },
        _show:function(el){
            var opts = this.opts;
            switch(this.opts.effects.effectTypeOpen) {
                case 'slide':
                    el.stop(true,true).delay(opts.TimeBeforeOpening)
                        .slideDown(opts.effects.effectSpeedOpen,opts.effects.effectOpen);
                    break;
                case 'fade':
                    el.stop(true,true).delay(opts.TimeBeforeOpening)
                        .fadeIn(opts.effects.effectSpeedOpen,opts.effects.effectOpen);
                    break;
                    default:el.stop(true,true).delay(opts.TimeBeforeOpening)
                        .show(opts.effects.effectSpeedOpen,opts.effects.effectOpen);
            }
        },
        _closeList:function(el){
            var opts = this.opts;
            switch(opts.effects.effectTypeClose) {
                case 'slide':el.slideUp(opts.effects.effectSpeedClose,opts.effects.effectClose);
                break;
                case 'fade':el.fadeOut(opts.effects.effectSpeedClose,opts.effects.effectClose);
                break;
                default:el.hide(opts.effects.effectSpeedClose,opts.effects.effectClose);
            }
        },
        _closeAll:function(){
            if(!$('#jMenu').isHovered()){
                $('#jMenu ul').each(function(){
                    $.jMenu._closeList($(this));
                });
            }
        },
        _IsParent:function(el){
            if(el.next().is('ul'))return true;
            else return false;
        },
        _returnUlWidth:function(el){
            switch(this.opts.ulWidth){
                case "auto":
                    this.ULWidth=parseInt(el.parent().outerWidth());
                break;
            default:
                this.ULWidth=parseInt(this.opts.ulWidth);
            }
            return this.ULWidth;
        },
        _animateText:function(el){
            var paddingInit=parseInt(el.css('padding-left'));
            el.hover(function(){
                $(this).stop(true,true).animate({
                    paddingLeft:paddingInit+opts.paddingLeft
                },100);
            },function(){
                $(this).stop(true,true).animate({paddingLeft:paddingInit},100);
            });
        },
        _isReadable:function(){
            if($("a.fNiv").length>0)return true;
            else return false;
        },
        _error:function(){
            alert('Please, check you have the \'.fNiv\' class on your first level links.');
        }
    };
    jQuery.fn.jMenu=function(options){
        if($.jMenu._isReadable()) $.jMenu.init(options);
        else $.jMenu._error();
    };
})(jQuery);